from PIL import Image

image_file = 'rotated_05.tif'

image = Image.open(image_file).convert('L')

histo = image.histogram()
#print histo
histo_string = ''
count = 0
for i in histo:
  histo_string += str(i) + "\n"
  count = count + i

print(histo_string)
print count